package com.ruitu.health_2.ui.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ruitu.arad.base.base_list.ListBaseAdapter;
import com.ruitu.arad.base.base_list.SuperViewHolder;
import com.ruitu.arad.util.ScreenUtils;
import com.ruitu.arad.util.SizeUtils;
import com.ruitu.health_2.R;
import com.ruitu.router_module.bean.product.Activity;
import com.ruitu.router_module.util.GlideUtil;

// 八个模块下面的活动列表
public class ModelActivityListAdpter extends ListBaseAdapter<Activity> {
    public ModelActivityListAdpter(Context context) {
        super(context);
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_common_activity_list;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        ImageView icon = holder.getView(R.id.icon);
        TextView tv_name = holder.getView(R.id.tv_name);
        TextView tv_subname = holder.getView(R.id.tv_subname);
        TextView tv_addr = holder.getView(R.id.tv_addr);

        int screenWidth = ScreenUtils.getScreenWidth();
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) icon.getLayoutParams();
        params.width = screenWidth - SizeUtils.dp2px(20);
        params.height = params.width / 2;
        icon.setLayoutParams(params);

        Activity activity = mDataList.get(position);
        tv_name.setText(activity.getTitle());
        tv_addr.setText(activity.getAddress());
        tv_subname.setText(activity.getContent());

        GlideUtil.loadImg(activity.getImgUrl(), icon);
    }
}
